#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

// set NOISY_TEST to 0 to remove printfs from output
#define NOISY_TEST 1

int main() {
    int i;
    int seed = 500;
    int numPlayer = 2;
    int r, handCount;
	int x,y;

    int k[10] = {adventurer, council_room, feast, gardens, mine
               , remodel, smithy, village, baron, great_hall};
    struct gameState G;
    int maxHandCount = 5;

	int salvagers[MAX_HAND];
	for (i = 0; i < MAX_HAND; i++) {
		salvagers[i] = salvager;
	}

	memset(&G, 23, sizeof(struct gameState));   // clear the game state
	r = initializeGame(numPlayer, k, seed, &G); // initialize a new game
	G.handCount[0] = 5; // set hand count
	G.numActions = 5; // set action count

	#if (NOISY_TEST == 1)
		printf("Player 0: %d cards, %d buys, %d coins\n", G.handCount[0], G.numBuys, G.coins);
		printf("TESTING SALVAGER\n");
	#endif
	
	memcpy(G.hand[0], salvagers, sizeof(int) * G.handCount[0]);  // sets all cards in hand to salvager
	
	for (handCount = 1; handCount <= maxHandCount; handCount++)
    {
		x = handCard(handCount - 1, &G); // get the index number of the card based on the enum CARD in dominion.h
		y = getCost(x);

		#if (NOISY_TEST == 1)
			printf("Player %d, Card ENUM Value = %d, Cost = %d\n", 0, x, y);
		#endif
	}
	
	for (i = 0; i < 2; i++) { // iterate twice
		playCard(0, 1, -1, -1, &G); // plays a salvager, and trash another salvager, +1 buy & trash a card and gain gold equal to cost
		#if (NOISY_TEST == 1)
			printf("Player 0: %d cards, %d buys, %d coins\n", G.handCount[0], G.numBuys, G.coins);
		#endif
		for (handCount = 1; handCount <= maxHandCount; handCount++) {
			x = handCard(handCount - 1, &G); // get the index number of the card based on the enum CARD in dominion.h
			y = getCost(x);

			#if (NOISY_TEST == 1)
				printf("Player %d, Card ENUM Value = %d, Cost = %d\n", 0, x, y);
			#endif
		}
	}

    printf("\nAll salvager tests completed!\n");

    return 0;
}
